package br.elsa.survey.dao;

import java.util.List;

import javax.ejb.Stateful;
import javax.persistence.EntityManager;

import br.elsa.survey.dao.exceptions.DataNotFoundException;
import br.elsa.survey.domain.survey.Survey;

/**
 * DAO to manipulate {@link Survey} database data.
 * 
 * <p>
 * This component is an EJB with no interface. It is meant to by accessed just
 * by local references.
 * </p>
 * 
 * @author diego
 * @since 07/11/2010
 */
@Stateful
public class SurveyDao extends Dao<Survey> {

	private static final long serialVersionUID = -6890765237202456989L;

	public SurveyDao() {

	}

	/**
	 * Constructor used by test classes to resolve dependencies
	 * 
	 * @param entityManager
	 */
	public SurveyDao(EntityManager entityManager) {
		super(entityManager);
	}

	/**
	 * Find all registered surveys in the system
	 * 
	 * @return List of surveys
	 * @throws DataNotFoundException Thrown in case of no survey is found
	 */
	public List<Survey> findAll() throws DataNotFoundException {
		return findAll(Survey.class);
	}

	public int surveysCount() {
		return count(Survey.class);
	}

}
